package com.csu.device.web;


import com.alibaba.fastjson.JSONObject;
import com.csu.device.service.BehariorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/behavior")
public class BehaviorController {

    @Autowired
    private BehariorService behariorService;

    /**
     * @param
     * @return
     * @throws
     */
    @RequestMapping(value = "/findOlderError", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public  List<Map<String,Object>> findOlderError(@RequestBody JSONObject jsonObject){
        List<String> ids = (List<String>) jsonObject.get("ids");
        return behariorService.getOlderErrorByOlderId(ids);
    }

    /**
     * @param jsonObject  根据房间id查询异常信息
     * @return
     */
    @RequestMapping(value = "/findErrorByFamilyId", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public  List<Map<String,Object>> findErrorByFamilyId(@RequestBody JSONObject jsonObject){
        List<String> familyIds = (List<String>) jsonObject.get("ids");
        return behariorService.findErrorByFamilyId(familyIds);
    }

}
